<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<div style="padding: 10px;">
	<form class="op-form" id="editForm" name="editForm" method="post">
		<input type="hidden" name="id" value="${roleEnt.id }">
		<table>
			<tr>
				<td>名称:</td>
				<td>
					<input class="easyui-validatebox" name="name" validType="length[1,100]" value="${roleEnt.name }">
				</td>
			</tr>
			<tr>
				<td>Code:</td>
				<td>
					<input class="easyui-validatebox" name="code" required="true" validType="length[2,100]" value="${roleEnt.code }">
				</td>
			</tr>
			<tr>
				<td>状态:</td>
				<td>
					<select id="status" name="status">
						<option value="0">停用</option>
						<option value="1">在用</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>描述:</td>
				<td>
					<textarea class="easyui-validatebox" name="description" validType="length[0,100]" style="height:100px;">${roleEnt.description }</textarea>
				</td>
			</tr>
			<tr>
				<td>
					<a href="#" class="easyui-linkbutton" icon="icon-ok" onclick="$('#editForm').submit();">提交</a>
				</td>
				<td>
					<a href="#" class="easyui-linkbutton" icon="icon-cancel" onclick="editForm.reset()">重置</a>
					<a href="#" class="easyui-linkbutton" icon="icon-redo" onclick="$('#dataGrid').show();$('#opPanel').panel('close');">返回</a>
				</td>
			</tr>
		</table>
	</form>
</div>

<script type="text/javascript">

	$(document).ready(function(){
		$('#status option[value='+ ${roleEnt.status} +']').attr('selected', true);
	
		$('#editForm').form({
			onSubmit: function(){
				if($(this).form('validate')){
					ajaxEdit();
				}else{
					return false;
				}
			}
		});
	});
	
	function ajaxEdit(){
		var actionURL = "role.action?command=update";
		var params = jQuery("#editForm").dataForAjax().data;
			
		jQuery.ajax({
			url: actionURL,
			type: "post",
			cache: false,
			data: params,
			success: function(result){
				if("true" == result){
					$.messager.alert("友情提示", "您的操作成功!", "info", function(){
						clearSels();
						setBtn(true);
						$('#tt').datagrid('reload');
						$("#dataGrid").show();
						$("#opPanel").panel("close");
					});
				}else{
					$.messager.alert("友情提示", "您的操作失败!", "error");
				}
			}
		});
	}
	
</script>